<template>
  <div>
    <h1>反馈回应</h1>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column
        prop="userName"
        label="用户名称"
        width="180"
      ></el-table-column>
      <el-table-column
        prop="feedbackContent"
        label="反馈内容"
        width="180"
      ></el-table-column>
      <el-table-column prop="feedbackStatus" label="目前状态" width="180">
        <template slot-scope="scop">
          <span v-if="scop.row.feedbackStatus === 0">等待处理</span>
          <span v-if="scop.row.feedbackStatus === 1">处理完成</span>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            v-if="scope.row.feedbackStatus === 0"
            size="mini"
            type="danger"
            @click="audit(scope.$index, scope.row)"
          >
            审核
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        :page-sizes="[1, 2, 3, 4]"
        :current-page="pageNum"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
  import { getFeedbackList, changesFeedbackStatus } from '@/api/customer'
  export default {
    name: 'Index',
    data() {
      return {
        pageNum: 0,
        pageSize: 3,
        total: 20,
        tableData: [
          {
            feedbackId: '',
            userId: '',
            userName: '',
            feedbackContent: '',
            feedbackStatus: '',
            createTime: '',
            updateTime: '',
            delFlag: '',
          },
        ],
        dialogFormVisible: false,
        form: {
          faqId: '',
          faqContent: '',
          faqAnswer: '',
          lookNums: '',
          createTime: '',
          updateTime: '',
          delFlag: '',
        },
        formLabelWidth: '120px',
      }
    },
    mounted() {
      console.log('mounted...')
      this.getFaqList1()
    },
    methods: {
      getFaqList1() {
        getFeedbackList(this.pageNum, this.pageSize).then((res) => {
          this.tableData = res.data
          this.total = res.total
          console.log(res)
        })
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`)
        this.pageSize = val
        this.getFaqList1()
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`)
        this.pageNum = val
        this.getFaqList1()
      },
      audit(index, row) {
        console.log(index, row)
        changesFeedbackStatus(row).then((res) => {
          this.getFaqList1()
          console.log(res)
        })
      },
    },
  }
</script>

<style scoped></style>
